package com.shangxia.feign.client.fallBack;

import com.shangxia.feign.client.ProductClient;
import com.shangxia.feign.model.SX_Product;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author zhouya24
 * @date 2021/11/18 15:26
 * @apiNote
 */

@Slf4j
@Component
public class ProductClientFallBackFactory implements FallbackFactory<ProductClient> {
    @Override
    public ProductClient create(Throwable throwable) {
        return new ProductClient() {
            @Override
            public SX_Product queryById(Long id) {
                log.error("productservice 服务异常", throwable);
                return new SX_Product();
            }

            @Override
            public List<SX_Product> listByIds(String ids) {
                log.error("productservice 服务异常", throwable);
                return null;
            }

            @Override
            public List<SX_Product> listByIds(List<Long> ids) {
                log.error("productservice 服务异常", throwable);
                return null;
            }
        };
    }
}
